#include <stdio.h>
#include <stdlib.h>
#include "scheduler.h"

int main()
{
  int n,m,i;
  scanf("%d %d",&n,&m);
  unsigned long *A=malloc(m*sizeof(unsigned long));
  char **B=malloc(m*sizeof(char *));
  for(i=0;i<n;i++)
  {
    B[i]=malloc(8*sizeof(char));
    scanf("%ld %s",&A[i],B[i]);
  }
  BuildMinHeap(A,B,n);
  for(i=0;i<m;i++)
  {
    printf("%s\n",B[0]);
    Change(A,B,n);
  }
}
